
Title : Appendix A ; The Windows API DLL calls.
	By : Duncan Bushaw
	Published on : March 22, 2007.

Contents :
	- CheckMenuItem
	- CheckMenuRadioItem
	- CreatePopupMenu
	- DestroyMenu
	- EnableMenuItem
	- HiliteMenuItem
	- InsertMenuItem
	- SetMenuDefaultItem
	- SetMenuInfo
	- SetMenuItemBitmaps
	- SetMenuItemInfo
	- TrackPopupMenuEx
	
---------------------------------------------------------------------------------------------------------------------------------------------
CheckMenuItem :
	This function either checks or unchecks the menuitem specified.
LB Syntax :
	FUNCTION CheckMenuItem(hmenu, uIDCheckltem, uCheck)
		CALLDLL #user32, "CheckMenultem",_
			hmenu As Long,_
			ulDCheckltem As Ulong,_
			uCheck As Ulong,_
			CheckMenultem As Ulong
		END FUNCTION
Parameters :
	hmenu [in] ; The handle of the menu containing the menuitem to check or uncheck.
	ulDCheckltem [in] ; The menuitem to check or uncheck, as determined  by the uCheck parameter.
	uCheck [in] ; Flags that control interpretation of the ulDCheckltem parameter, and either check or uncheck the menuitem.
		This value must be a combination of ( MF_BYCOMMAND or MF_BYPOSITION ) and ( MF_CHECKED or MF_UNCHECKED  ). 
		MF_BYCOMMAND = 0. Uses the identifier of a menuitem.
		MF_BYPOSITION = 1024. Uses zero based relative position of a menuitem in a menu.
		MF_UNCHECKED = 0. Indicates that the menuitem is unchecked.
		MF_CHECKED =8. Indicates that the menitem is checked.
		Valid values for this parameter are 0, 8, 1024, and 1032.
	CheckMenuItem [out] ; Return value. If the menuitem doesn't exist, this value is -1.
		This value is the previous state of the menuitem (0 or 8). 
		The example program pays no attention to this parameter.
Remarks :
	In the example program uCheck is either 0 or 8 and hmenu is always MPM, and uIDCheckItem is the ID number of the menuitem.
	For a menuitem that is a submenu, uIDCheckItem must point to the zero based position of the menuitem, and hmenu must be 
	the menu containing the menuitem, and uCheck must be either 1024 or 1032. The example program does not use this method.

---------------------------------------------------------------------------------------------------------------------------------------------
CheckMenuRadioItem :
	This function checks a menuitem and makes it a radiomenuitem, and at the same time, it unchecks all 
	other menuitems in the associated group and clears the radiomenuitem type flag for those items.
LB Syntax :
	FUNCTION CheckMenuRadioItem(hmenu, idFirst, idLast, idCheck, uFlags)
		CALLDLL #user32, "CheckMenuRadioItem",_
			hmenu As Long,_
			idFirst As Ulong,_
			idLast As Ulong,_
			idCheck As Ulong,_
			uFlags As Ulong,_
			CheckMenuRadioItem As Boolean
		END FUNCTION
Parameters :
	hmenu [in] ; The handle of the menu that contains the menuitem. 
	idFirst [in] ; The first menuitem in a group of menuitems.
	idLast [in] ; The last menuitem in a group of menuitems.
	idCheck [in] ; The menuitem to check, as determined  by the uFlags parameter.
	uFlags [in] ; Flags that control interpretation of the idFirst, the idLast, and the idCheck parameters. 
		MF_BYCOMMAND = 0. Uses the identifier of a menuitem.
		MF_BYPOSITION = 1024. Uses zero based relative position of a menuitem in a menu.
		Valid values for this parameter are 0 and 1024. 
	CheckMenuRadioItem [out] ; Return value. An error is indicated with a value of 0.  All other values mean it worked.
		The GetLastError dll call must be used to get the extended error information.
		The example program pays no attention to this parameter.
Remarks :
	This function sets the MFT_RADIOCHECK and the MFS_CHECKED flag for the menuitem specified 
	by idCheck and clears both flags for all other menuitems in a group.
	The selected menuitem is shown with a bullet bitmap and not a checkmark bitmap.

---------------------------------------------------------------------------------------------------------------------------------------------
CreatePopupMenu :
	This function creates a drop down menu, submenu, or shortcut menu.
	This menu is empty until menuitems are added.
LB Syntax :
	FUNCTION CreatePopupMenu()
		CALLDLL #user32, "CreatePopupMenu",_
			CreatePopupMenu AS Long
		END FUNCTION
Parameters :
	CreatePopupMenu [out] ; Return value. An error is indicated with a value of 0.
		Any other value is the handle of the new menu.
		The GetLastError dll call must be used to get the extended error information.
Remarks :
	A program can insert the new menu into any menu or it can display a popupmenu 
	by using the TrackPopupMenu or TrackPopupMenuEx dll calls.
	Resources used with a menu that is assigned to a window are freed automatically.
	If the menu is not assigned to a window, a program must free resources used with the menu before closing.
	A program frees these resources by calling the DestroyMenu function.
	The example program uses the DestroyMenu function.
	If using Windows 95/98/Me a maximum of 16,364 menu handles can be assigned.
	No limit is given in the MSDN online database for other versions of Windows.

---------------------------------------------------------------------------------------------------------------------------------------------
DestroyMenu :
	This function destroys a menu and frees memory that it occupies. 
LB Syntax :
	FUNCTION DestroyMenu(hMenu)
		CALLDLL #user32, "DestroyMenu",_
			hMenu As Long,_
			DestroyMenu As Boolean
		END FUNCTION
Parameters :
	hMenu [in] ; The handle to a menu to be destroyed. 
	DestroyMenu [out] ; Return value. An error is indicated with a value of 0.  All other values mean it worked.
		The GetLastError dll call must be used to get the extended error information.
Remarks :
	Before a program closes it must use the DestroyMenu dll call to destroy a menu not assigned to a window.
	Any menu that is assigned to a window is destroyed automatically when the program closes. 
	DestroyMenu will destroy the menu and all its submenus, that is to say it is a recursive function.

---------------------------------------------------------------------------------------------------------------------------------------------
EnableMenuItem :
	This function enables or disables the specified menuitem. 
LB Syntax :
	FUNCTION EnableMenuItem(hMenu, uIDEnableItem, uEnable)
		CALLDLL #user32, "EnableMenuItem",_
			hMenu As Long,_
			uIDEnableItem As Ulong,_
			uEnable As Ulong,_
			EnableMenuItem As Boolean
		END FUNCTION
Parameters :
	hMenu [in] ; The handle to a menu. 
	uIDEnableItem [in] ; The menuitem to be enabled or disabled, as determined by the uEnable parameter.
	uEnable [in] ; Flags that control interpretation of the uIDEnableItem parameter and sets the state of the menuitem.
		This value must be  (MF_BYCOMMAND or MF_BYPOSITION) and (MF_ENABLED or MF_DISABLED or MF_GRAYED). 
		MF_BYCOMMAND = 0. Uses the identifier of a menuitem.
		MF_BYPOSITION = 1024. Uses zero-based relative position of a menuitem in a menu.
		MF_ENABLED = 0. Indicates that the menuitem is enabled and not grayed.
		MF_GRAYED =1. Indicates that the menuitem is disabled and grayed.
		MF_DISABLED = 2. Indicates that the menuitem is disabled, but not grayed.
		Valid values for this parameter are 0, 1, 2, 1024, 1025, and 1026.
	EnableMenuItem [out] ; Return Value. If the menuitem doesn't exist the value is -1.
		This returns the previous state of the menuitem (0, 1, or 2). 
		The example program pays no attention to this parameter.
Remarks :
	A program must use the MF_BYPOSITION flag to specify the correct menu handle.
	If the menu handle to the menu bar is specified, the top-level menu item (an item in the menu bar) is affected.
	To set the state of an item in a drop down menu or submenu by position, a program 
	must specify a handle to the drop-down menu or submenu. 
	When a program specifies the MF_BYCOMMAND flag, the system checks all items that open submenus 
	in the menu identified by the specified menu handle. Unless duplicate menuitems are present, specifying 
	the menu handle to the menu bar is sufficient. 

---------------------------------------------------------------------------------------------------------------------------------------------
HiliteMenuItem :
	This function highlights or unhighlights a menuitem in a menu. 
LB Syntax :
	FUNCTION HiliteMenuItem(hwnd, hmenu, uItemHilite, uHilite)
		CALLDLL #user32, "HiliteMenuItem",_
			hwnd As Long,_
			hmenu As Long,_
			uItemHilite As Ulong,_
			uHilite As Ulong,_
			HiliteMenuItem As Boolean
		END FUNCTION
Parameters :
	hwnd [in] ; The handle to the window that contains the menu. 
	hmenu [in] ; The handle to the menu bar that contains the menuitem. 
	uItemHilite [in] ; The menuitem to be highlighted or unhighlighted, as determined by the uHilite parameter.
	uHilite [in] ; Controls the interpretation of the uItemHilite parameter and whether the menuitem is highlighted.
		This value must be  (MF_BYCOMMAND or MF_BYPOSITION) and MF_HILITE or MF_UNHILITE). 
		MF_BYCOMMAND = 0. Uses the identifier of a menuitem.
		MF_BYPOSITION = 1024. The zero-based relative position of a menuitem in a menu.
		MF_UNHILITE = 0. Removes highlighting from the menu item.
		MF_HILITE = 128. Highlights the menu item.
	HiliteMenuItem [out] ; Return Value. An error is indicated by a value of 0. 
		All other values mean the function worked.
		There is no the extended error information for this dll call.
Remarks :
	The MF_HILITE and MF_UNHILITE flags can only be used with the HiliteMenuItem dll call; they do not work with the ModifyMenu dll call. 

---------------------------------------------------------------------------------------------------------------------------------------------
InsertMenuItem :
	This function inserts a new menuitem in to a menu at the specified position.
LB Syntax :
	FUNCTION InsertMenuItem(hMenu, uItem, fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwTypeData$, hbmpItem)
		lpmii.fMask.struct = 463 ' This value allows all members of the MENUITEMINFO structure to be set.
		lpmii.fType.struct = fType
		lpmii.fState.struct = fState
		lpmii.wID.struct = wID
		lpmii.hSubMenu.struct = hSubMenu
		lpmii.hbmpChecked.struct = hbmpChecked
		lpmii.hbmpUnchecked.struct = hbmpUnchecked
		lpmii.dwTypeData$.struct = dwTypeData$
		lpmii.cch.struct = LEN(lpmii.dwTypeData$.struct)
		lpmii.hbmpItem.struct = hbmpItem
		CALLDLL #user32, "InsertMenuItemA",_
			hMenu AS Long,_
			uItem AS Ulong,_
			fByPosition AS Boolean,_
			lpmii AS Struct,_
			InsertMenuItem AS Boolean
		END FUNCTION
Parameters :
	hMenu [in] ; The handle to the menu in which the new menu item is inserted. 
	uItem [in] ; The identifier or the position of the menuitem before which to insert the new menuitem. 
		The meaning of this parameter depends on the value of fByPosition. 
	fByPosition [in] ; If this parameter is FALSE = 0, uItem is a menuitem identifier.
		If this parameter is TRUE = 1, uItem  is a menuitem position. 
	lpmii [in] ; The pointer to the  MENUITEMINFO structure that holds the information about the new menuitem. 
	InsertMenuItem [out] ; Return Value. An error is indicated by a value of 0. All other values mean it worked.
		The GetLastError dll call must be used to get the extended error information.
Remarks :
	The program must call the DrawMenuBar dll call whenever a menu that is attached
	to a window changes, whether or not the menu is showing.
	In order for keyboard accelerators to work with bitmap or owner-drawn menuitems,
	the owner of the menu must process the WM_MENUCHAR message.

---------------------------------------------------------------------------------------------------------------------------------------------
SetMenuDefaultItem :
	This function sets the default menu item for the specified menu.
LB Syntax :
	FUNCTION SetMenuDefaultItem(hMenu, uItem)
		CALLDLL #user32, "SetMenuDefaultItem",_
			hMenu AS Long,_
			uItem AS Ulong,_
			fByPos  AS Ulong,_
			SetMenuDefaultItem AS Boolean
		END FUNCTION
Parameters :
	hMenu [in] ; The handle to the menu to set the default item for. 
	uItem [in] ; The identifier or the position of the menuitem to set or -1 for no default item. This parameter depends on the value of fByPos. 
	fByPos [in] ; If this parameter is FALSE = 0, uItem is a menuitem identifier.
		If this parameter is TRUE = 1, uItem  is a menuitem position. 
	SetMenuDefaultItem [out] ; Return Value. An error is indicated by a value of 0. All other values mean it worked.
		The GetLastError dll call must be used to get the extended error information.
Remarks :
	This function acts like CheckMenuRadioItem in that when it sets a default menuitem it clears the default flag in all the other menuitems in a menu .

---------------------------------------------------------------------------------------------------------------------------------------------
SetMenuInfo :
	This function sets information for a menu and/or its submenus.
LB Syntax :
	FUNCTION SetMenuInfo(hmenu, fMask, dwStyle)
		lpcmi.fMask.struct = fMask
		lpcmi.dwStyle.struct = dwStyle
		CALLDLL #user32, "SetMenuInfo",_
			hmenu AS Long,_
			lpcmi AS Struct,_
			SetMenuInfo AS Boolean
		END FUNCTION
Parameters :
	hmenu [in] ; The handle to a menu. 
	lpcmi [in] ; The pointer to a MENUINFO structure for a menu. 
	SetMenuInfo [out] ; Return Value. An error is indicated by a value of 0. All other values mean it worked.
		The GetLastError dll call must be used to get the extended error information.
Remarks :

---------------------------------------------------------------------------------------------------------------------------------------------
SetMenuItemBitmaps :
	This function associates the specified bitmap with a menuitem.
	Whether the menuitem is selected or clear, the system displays the appropriate bitmap next to the menuitem. 
LB Syntax :
	FUNCTION SetMenuItemBitmaps(hMenu, uPosition, hBitmapUnchecked, hBitmapChecked)
		CALLDLL #user32, "SetMenuItemBitmaps",_
			hMenu As Long,_
			uPosition As Ulong,_
			uFlags As Ulong,_
			hBitmapUnchecked As Long,_
			hBitmapChecked As Long,_
			SetMenuItemBitmaps As Boolean
		END FUNCTION
Parameters :
	hMenu [in] ; The handle to the menu containing the item to receive new check-mark bitmaps. 
	uPosition [in] ; The identifier or the position of the menuitem, as determined by the uFlags parameter. 
	uFlags [in] ; This specifies how the uPosition parameter is interpreted. 
		MF_BYCOMMAND = 0. Uses the identifier of a menuitem.
		MF_BYPOSITION = 1024. Uses the zero based relative position of a menuitem in a menu.
	hBitmapUnchecked [in]  ; The handle to the bitmap displayed when the menuitem is not selected. 
	hBitmapChecked [in] ; The handle to the bitmap displayed when the menuitem is selected. 
	SetMenuItemBitmaps [out] ; Return Value. An error is indicated by a value of 0. All other values mean it worked.
		The GetLastError dll call must be used to get the extended error information.
Remarks
	If either the hBitmapUnchecked or hBitmapChecked parameter is NULL, 
	the system displays nothing next to the menu item for the corresponding check state.
	If both parameters are NULL, the system displays the default check-mark bitmap when the item is selected, 
	and removes the bitmap when the item is not selected. 
	When the menu is destroyed, these bitmaps are not destroyed; it is up to the program to destroy them. 
	The selected and clear bitmaps should be monochrome. The system uses the Boolean AND operator to combine 
	bitmaps with the menu so that the white part becomes transparent and the black part becomes the menuitem color. 
	If you use color bitmaps, the results may be undesirable.
	Use the GetSystemMetrics function with the CXMENUCHECK and CYMENUCHECK values to retrieve the bitmap dimensions.

---------------------------------------------------------------------------------------------------------------------------------------------
SetMenuItemInfo :
	This function changes information about a menuitem.
LB Syntax :
	FUNCTION SetMenuItemInfo(hMenu, fMask, fType, fState, wID, hSubMenu, hbmpChecked, hbmpUnchecked, dwTypeData$, hbmpItem)
		lpmii.fMask.struct = fMask
		lpmii.fType.struct = fType
		lpmii.fState.struct = fState
		lpmii.wID.struct = wID
		lpmii.hSubMenu.struct = hSubMenu
		lpmii.hbmpChecked.struct = hbmpChecked
		lpmii.hbmpUnchecked.struct = hbmpUnchecked
		lpmii.dwTypeData$.struct = dwTypeData$
		lpmii.cch.struct = LEN(lpmii.dwTypeData$.struct)
		lpmii.hbmpItem.struct = hbmpItem
		CALLDLL #user32, "SetMenuItemInfoA",_
			hMenu As Long,_
			wID As Ulong,_
			0 As Boolean,_
			lpmii As Struct,_
			SetMenuItemInfo As Boolean
		END FUNCTION
Parameters :
	hMenu [in] ; The handle to a menu that contains a menuitem. 
	uItem [in] ; The identifier or the position of the menuitem to change, as determined by the fByPosition parameter. 
	fByPosition [in] ; If this parameter is FALSE = 0, uItem is a menuitem identifier.
		If this parameter is TRUE = 1, uItem  is a menuitem position. 
	lpmii [in] ; The pointer to a MENUITEMINFO structure that holds information about a menuitem. 
	SetMenuItemInfo [out] ; Return Value. An error is indicated by a value of 0. All other values mean it worked.
		The GetLastError dll call must be used to get the extended error information.
Remarks :
	The program must call the DrawMenuBar dll call whenever a menu that is attached
	to a window changes, whether or not the menu is showing.
	In order for keyboard accelerators to work with bitmap or owner-drawn menuitems,
	the owner of the menu must process the WM_MENUCHAR message.

---------------------------------------------------------------------------------------------------------------------------------------------
TrackPopupMenuEx :
	This function displays a menu at the specified location and tracks the selection of items on the menu.
	This menu can be displayed anywhere on the screen.
LB Syntax :
	CALLDLL #user32, "TrackPopupMenuEx",_
		hmenu As Long,_
		fuFlags As Ulong,_
		x As Long,_
		y As Long,_
		hwnd As Long,_
		lptpm AS Struct,_
		r As Long
          or
	CALLDLL #user32, "TrackPopupMenuEx",_
		hmenu As Long,_
		fuFlags As Ulong,_
		x As Long,_
		y As Long,_
		hwnd As Long,_
		0 AS Long,_
		r As Long
Parameters :
	hmenu [in] ; The handle to the shortcut menu to be displayed.
		This handle can be obtained by using the CreatePopupMenu dll call to create a new menu 
		or by using the GetSubMenu dll call to retrieve a handle to a menu associated with an existing menuitem. 
	fuFlags [in] ; Specifies function options. 
		Use one of the following flags to specify how the function positions the shortcut menu horizontally. 
			TPM_LEFTALIGN = 0. This positions the menu so that its left side is aligned with the coordinate set by the x parameter.
			TPM_CENTERALIGN = 4. This centers the menu horizontally relative to the coordinate set by the x parameter.
			TPM_RIGHTALIGN = 8. This positions the menu so that its right side is aligned with the coordinate set by the x parameter.
		Use one of the following flags to specify how the function positions the shortcut menu vertically.
			TPM_TOPALIGN = 0. This positions the menu so that its top side is aligned with the coordinate set by the y parameter.
			TPM_VCENTERALIGN = 16. This centers the menu vertically relative to the coordinate set by the y parameter.
			TPM_BOTTOMALIGN = 32. This positions the menu so that its bottom side is aligned with the coordinate set by the y parameter.
		Use the following flags to determine the user selection without having to set up a parent window for the menu. 
			TPM_NONOTIFY = 128. This does not send notification messages when the user clicks on a menu  item.
			TPM_RETURNCMD = 256. This returns the menuitem identifier of the user's selection in the return value.
		Use one of the following flags to specify which mouse button the shortcut menu tracks. 
			TPM_LEFTBUTTON = 0. The user can only select menuitems with the left mouse button.
			TPM_RIGHTBUTTON = 2. The user can select menuitems with both the left and right mouse buttons.
		Use any reasonable combination of the following flags to modify the animation of a menu.
			TPM_HORNEGANIMATION. This animates the menu from right to left.
			TPM_HORPOSANIMATION. This animates the menu from left to right.
			TPM_NOANIMATION. This displays menu without animation.
			TPM_VERNEGANIMATION. This animates the menu from bottom to top.
	`		TPM_VERPOSANIMATION. This animates the menu from top to bottom.
			For any animation to occur, the SystemParametersInfo function must set SPI_SETMENUANIMATION. 
			Also, all the TPM_*ANIMATION flags, except TPM_NOANIMATION, are ignored if menu fade animation is on, 
				see the SPI_GETMENUFADE flag in SystemParametersInfo. 
			Use the TPM_RECURSE flag to display a menu when another menu is already displayed.
				This is intended to support context menus within a menu. 
		Use one of the following flags to specify whether to accommodate horizontal or vertical alignment  with the excluded rectangle. 
			The excluded rectangle is a portion of the screen that the menu should not overlap; it is set by lptpm. 
			TPM_HORIZONTAL = 0. The system tries to accommodate the horizontal alignment before the vertical alignment.
			TPM_VERTICAL = 64. The system tries to accommodate the vertical alignment before the horizontal alignment.
		Windows XP: To have text layout from right-to-left, use TPM_LAYOUTRTL. By default, the text layout is left-to-right. 
	x [in] ; The horizontal screen coordinates of the menu.
	y [in] ; The vertical screen coordinates of the menu.
	hwnd [in] ; The handle to the window that owns the shortcut menu. This window receives all messages from the menu.
		The window does not receive a WM_COMMAND message from the menu until the function returns.
		If you specify TPM_NONOTIFY in the fuFlags parameter, the function does not send messages to the window identified by hwnd.
			 However, you must still pass a window handle in hwnd. It can be any window handle from your program.
	lptpm [in] ; The pointer to a TPMPARAMS structure that specifies an area of the screen the menu should not overlap.
		This parameter can be 0 AS Long.
	SetMenuItemInfo [out] ; Return Value. If the user cancels the menu without making a selection, or if an error occurs, then the value is zero.
		If TPM_RETURNCMD is specified in the fuFlags parameter, then the value is the menuitem identifier of the menuitem that was selected.
			If no menuitem was selected then the value is 0.
		If  TPM_RETURNCMDis not specified in the fuFlags parameter, an error is indicated by a value of 0. All other values mean it worked.
			The GetLastError dll call must be used to get the extended error information.
Remarks :
	Call GetSystemMetrics(SM_MENUDROPALIGNMENT) to determine the correct horizontal alignment flag (TPM_LEFTALIGN or TPM_RIGHTALIGN)
	and/or horizontal animation direction flag (TPM_HORPOSANIMATION or TPM_HORNEGANIMATION) to pass to TrackPopupMenu or TrackPopupMenuEx.
	To display a context menu for a notification icon, the current window must be the foreground window before the program calls TrackPopupMenu 
	or TrackPopupMenuEx. Otherwise, the menu will not disappear when the user clicks outside of the menu or the window that created the menu . 

---------------------------------------------------------------------------------------------------------------------------------------------
